Skip to content

AMT coverage: g1-knownmagic-enum-prefix-b - #202

Open
thedavidmeister wants to merge 2 commits into
mainfrom
2026-08-22-amt-g1-knownmagic-enum-prefix-b
Open

AMT coverage: g1-knownmagic-enum-prefix-b#202
thedavidmeister wants to merge 2 commits into
mainfrom
2026-08-22-amt-g1-knownmagic-enum-prefix-b

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Adversarial mutation-test coverage for group g1-knownmagic-enum-prefix-b (30 behaviours across 5 units), scanned commit bba50a7.

Method: all 76 mutants were first probed against the pre-existing suite (attribution pass), then each surviving mutant got a new discriminating test and was re-probed with --only until killed. No existing test was deleted, weakened, or edited to pass under a mutation.

Behaviour matrix

# Behaviour Mutation(s) Verdict Killing test
1 KnownMagic: 19 discriminant values discriminant edits (M01 AddressList, M02 OpMetaV1) KILLED (M02 pre-existing, M01 new) test_op_meta_v1; test_address_list, test_all_discriminants_pinned
2 to_prefix_bytes big-endian u64 -> [u8;8] to_be_bytes -> to_le_bytes (M03) KILLED (pre-existing) test_authoring_meta_v1 et al
3 TryFrom: guard arms value->variant (19 arms) each arm -> Err (M04-M22) KILLED (10 pre-existing, 9 new) roundtrip/type tests; test_try_from_u64_roundtrip_all
4 TryFrom fallback Err(UnknownMagic) _ -> Ok(OpMetaV1) (M23) KILLED (new) test_try_from_u64_unknown_magic
5 KnownMagic strum kebab-case parse/display serialize_all -> UPPERCASE (M24) KILLED (new) test_strum_kebab_case_parse_display
6 KnownMagic serde kebab-case rename rename_all -> UPPERCASE (M25) KILLED (new) test_serde_kebab_case_roundtrip
7 len(): base 2 + four conditionals base->3; each conditional removed (M39-M43) KILLED (pre-existing) test_empty_item, oa_schema_map_key_roundtrip, dotrain roundtrips
8 hash(true) prefixed seq vs hash(false) bare map wrong prefix magic (M44); branch inverted (M45) KILLED (new) test_hash_bare_vs_document
9 cbor_encode via serde_cbor output reversed (M46) KILLED (pre-existing) oa_schema_map_key_roundtrip et al
10 cbor_encode_seq: prefix then items in order prefix dropped (M47); items reversed (M48) KILLED (pre-existing) test_build_empty, meta_seq_roundtrip
11 cbor_decode prefix detection -> len-=8, slice[8..] len adj removed (M49); slice not skipped (M50); detection inverted (M51) KILLED (pre-existing) meta_seq_roundtrip, order_builder/oracle tests
12 cbor_decode: track byte_offset per item track pushes len (M52) KILLED (new) test_cbor_decode_trailing_truncated_is_corrupt
13 cbor_decode EOF accepted only when is_eof && offset==len eof acceptance removed (M54); == -> <= (M53) KILLED (pre-existing); M53 equivalent (see notes) no_schema_key_encodes_as_before_roundtrip et al
14 cbor_decode final CorruptMeta guard empty checks removed (M55); final length check removed (M57); track/metas check removed (M56) KILLED (M55 pre-existing, M57 new); M56 equivalent (see notes) test_extract_from_meta_empty_data; test_cbor_decode_trailing_truncated_is_corrupt
15 unpack: dispatch to ContentEncoding::decode decode skipped (M58) KILLED (new) test_unpack_decodes_content_encoding
16 unpack_into: 13-magic whitelist else UnsupportedMeta DotrainV1 arm removed (M59); whitelist bypassed (M60) KILLED (new) test_unpack_into_whitelist
17 Serialize: keys 0/1 always, conditional 2/3/4, OaSchema key key/value edits (M61-M64) KILLED (pre-existing) test_empty_item, no_schema_key_encodes_as_before_roundtrip, oa_schema_map_key_roundtrip
18 Deserialize visitor: key dispatch + error paths + defaults unexpected-key ignored (M65); default Json (M66); missing payload (M67); unknown magic (M68); missing magic (M69) KILLED (M65/M66 pre-existing, M67-M69 new) non_oa_schema_extra_map_key_errors, no_schema_key_encodes_as_before_roundtrip; test_cbor_decode_missing_payload_errors, test_cbor_decode_unknown_magic_errors, test_cbor_decode_missing_magic_errors
19 TryFrom item -> String (utf8 error) / Vec lossy utf8 (M70); unpack skipped (M71) KILLED (new) test_try_into_string_invalid_utf8_errors, test_try_into_vec_decodes_encoding
20 ContentEncoding::encode: passthrough vs Deflate zlib Deflate -> passthrough (M31) KILLED (new) test_content_encoding_deflate_roundtrip
21 ContentEncoding::decode passthrough passthrough -> empty (M32) KILLED (pre-existing) authoring v2 / oracle type tests
22 decode Deflate: zlib, raw fallback, InflateError fallback removed (M33); error -> empty (M34) KILLED (new) test_content_encoding_decode_fixtures, test_content_encoding_decode_garbage_errors
23 content headers serde/strum kebab + mime renames mime renames (M35, M36); serde rename_all (M37); strum case (M38) KILLED (M35-M37 pre-existing, M38 new) test_empty_item, roundtrips; test_content_headers_strum_names
24 KnownMeta: 13 mapping arms magic->meta SolidityAbiV2 arm (M27); OpMetaV1 arm (M28); DotrainV1 swap (M29) KILLED (M27 pre-existing, M28/M29 new) test_into_meta_document; test_known_meta_try_from_magic
25 KnownMeta catch-all Err(UnsupportedMeta) _ -> Ok(OpV1) (M30) KILLED (new) test_known_meta_try_from_magic
26 KnownMeta strum kebab-case parse serialize_all -> UPPERCASE (M26) KILLED (new) test_known_meta_strum_parse_display
27 normalize_json: utf8 -> parse -> validate -> canonical validate skipped (M72); returns input (M73) KILLED (new) test_normalize_op_v1_rejects_invalid_symbol, test_normalize_op_v1_canonicalizes
28 normalize OpV1 arm passthrough (M74) KILLED (new) test_normalize_op_v1_rejects_invalid_symbol
29 normalize SolidityAbiV2 arm passthrough (M75) KILLED (new) test_normalize_solidity_abi_v2_rejects_bad_input
30 normalize InterpreterCallerMetaV1 arm passthrough (M76) KILLED (new) test_normalize_interpreter_caller_rejects_empty_methods

Equivalent mutants (recorded, not killable)

  • M53 error.offset() == len -> <=: with serde_cbor 0.11.2 an eof error's offset is always the end of input (== len), verified empirically for clean ends, truncated u64 headers, truncated arrays and missing values. The else branch is unreachable; the effective trailing-truncation guard is the final length check (now pinned by test_cbor_decode_trailing_truncated_is_corrupt).
  • M56 track.len() != metas.len() -> false: both vectors are pushed in the same iteration and any push failure returns early, so the lengths can never differ at the guard.

Both are recorded in the audit issue about unreachable guard conditions.

QA

  • Discriminating tests: test_address_list, test_all_discriminants_pinned, test_all_prefixes_start_with_0xff, test_try_from_u64_roundtrip_all, test_try_from_u64_unknown_magic, test_strum_kebab_case_parse_display, test_serde_kebab_case_roundtrip, test_hash_bare_vs_document, test_cbor_decode_empty_is_corrupt, test_cbor_decode_trailing_truncated_is_corrupt, test_cbor_decode_trailing_garbage_errors, test_cbor_decode_missing_payload_errors, test_cbor_decode_missing_magic_errors, test_cbor_decode_unknown_magic_errors, test_unpack_decodes_content_encoding, test_unpack_into_whitelist, test_try_into_string_invalid_utf8_errors, test_try_into_vec_decodes_encoding, test_content_encoding_deflate_roundtrip, test_content_encoding_passthrough, test_content_encoding_decode_fixtures, test_content_encoding_decode_garbage_errors, test_content_headers_strum_names, test_known_meta_try_from_magic, test_known_meta_strum_parse_display, test_normalize_op_v1_canonicalizes, test_normalize_op_v1_rejects_invalid_symbol, test_normalize_solidity_abi_v2_rejects_bad_input, test_normalize_solidity_abi_v2_canonicalizes, test_normalize_interpreter_caller_rejects_empty_methods, test_normalize_passthrough_for_binary_metas - each fails on base under its target mutation (verified by mutation-probe pass 2: every re-probed mutant reports KILLED naming these tests as killers; probe logs per mutant)
  • Mutations applied: 76 exact-string mutants over crates/cli/src/meta/{magic.rs,mod.rs,normalize.rs}; the behaviour matrix above maps every mutation to its verdict and killing test. Pass 1 (pre-existing suite): 36 KILLED / 40 SURVIVED / 0 NO-RUN / 0 HARNESS-ERROR. Pass 2 (with new tests): all survivors KILLED except two mutants proven equivalent (M53 eof-offset ==-><=, M56 track/metas length check removal), documented in cbor_decode corrupt-meta guard carries unreachable sub-conditions (eof offset equality, track/metas length) — equivalent-mutant evidence #190.
  • Oracle: metadata-v1 spec (magic number table, mandatory keys 0/1, 0xff prefix rule, deflate content-encoding), handwritten cbor bytes per RFC 8949 with keccak256 computed over those literals (not over cbor_encode output), out-of-band generated zlib/raw-deflate fixtures pinned as byte literals, RFC 1950 CMF byte 0x78, and the CLI's documented kebab-case names (e.g. build's default rain-meta-document-v1) — all independent of the implementation under test.
  • Category check: assignment g1-knownmagic-enum-prefix-b lists 30 behaviours across 5 units (KnownMagic enum+prefix+TryFrom, RainMetaDocumentV1Item codec, ContentEncoding/Type/Language, KnownMeta+TryFrom, KnownMeta::normalize); all 30 probed and covered per the matrix — no behaviour left unprobed.

Issues filed from the adversarial pass (audit + adversarial labels): #186, #187, #188, #189, #190, #191, #203, #204, #216. (#217/#218 are accidental duplicates of #203/#204 from a re-dispatched run of this group and are marked as such.)

🤖 Generated with Claude Code

Independent re-verification (second g1 run, 2026-08-22)

A re-dispatched run of this group independently rebuilt the harness from scratch (fresh clone at bba50a7, its own 92-mutant file) and converged on the same matrix:

  • Pass 1 against the pre-existing suite: 40/86 killed, 46 survived, 0 no-run, 0 harness errors — same survivor set as the original run where the mutant sets overlap.
  • All survivors were then re-probed with --only against THIS branch's delivered tests (52 mutants including per-key Deserialize dispatch and per-mime rename probes the first pass did not carry): every non-equivalent mutant is KILLED by the tests on this branch; the two analytically equivalent mutants (eof-offset comparison, ContentEncoding kebab-vs-snake on single-word variants) survive as predicted and are documented in cbor_decode corrupt-meta guard carries unreachable sub-conditions (eof offset equality, track/metas length) — equivalent-mutant evidence #190.
  • The eof-offset equivalence was additionally proven from serde_cbor 0.11.2 source: both SliceRead eof paths (end() and byte-exhaustion) construct the error with offset == slice.len(), so error.offset() == len is always true for eof from a slice.
  • rainix-rs / static was red on formatting only; fixed by the style: rustfmt commit with no semantic change.

…ncoding, KnownMeta, normalize

Pins the behaviours that a 76-mutant probe pass showed the existing suite
does not discriminate:

- every KnownMagic discriminant (AddressList had no prefix test), the 0xff
  prefix invariant, TryFrom<u64> for all 19 variants plus the UnknownMagic
  fallback, and the strum/serde kebab-case names
- hash(false) vs hash(true) against handwritten cbor bytes
- cbor_decode corrupt-input guards: empty input, bare document prefix,
  truncated trailing bytes, non-cbor trailing bytes, missing mandatory
  keys 0/1, unknown magic values
- unpack content-encoding dispatch, the 13-magic unpack_into whitelist and
  its UnsupportedMeta rejections, String utf8 error path, Vec<u8> decode
- ContentEncoding deflate compresses (zlib CMF pinned) and roundtrips,
  zlib + raw-deflate decode fixtures, InflateError on garbage, passthrough
  arms, kebab-case strum names for the content headers
- KnownMeta TryFrom<KnownMagic> full mapping + UnsupportedMeta arm and its
  CLI-facing kebab-case names
- KnownMeta::normalize: canonicalization, validation rejection and parse
  errors for OpV1 / SolidityAbiV2 / InterpreterCallerMetaV1, binary
  passthrough

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@thedavidmeister, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 36 minutes

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 173488d7-2c35-4851-aab7-7976d5579d54

📥 Commits

Reviewing files that changed from the base of the PR and between bba50a7 and 9f6f444.

📒 Files selected for processing (3)
  • crates/cli/src/meta/magic.rs
  • crates/cli/src/meta/mod.rs
  • crates/cli/src/meta/normalize.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

rainix-rs-static failed on formatting only (clippy is clean); this is
cargo fmt --all with no semantic change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant